/*
 * bw_err.c
 *
 *  Created on: 2018年9月6日
 *  Author: Degang.Wu (windragon@126.com)
 *  Desc:
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "bw_errno.h"

static st_ErrMsg	g_erros[] = {
		{BWENC_ERROR_NONE, "success", "成功"},
		{BWENC_ERROR_UNKNOW, "unknow error", "未知错误" },
		{BWENC_ERROR_INVALID_PARAM, "invalid param", "参数不合法"},
		{BWENC_ERROR_DB_ERR, "database error", "数据库错误" },
		{BWENC_ERROR_USER_NOT_EXIST, "user is not exist", "用户不存在"},
		{BWENC_ERROR_PASSWORD_WRONG, "password is wrong", "密码错误"},
		{BWENC_ERROR_QUERY_EMPTY, "query empty", "查询为空" },
		{BWENC_ERROR_INVALID_MULTICAST, "invalid multicast address", "组播地址不合法"},
		{BWENC_ERROR_ILLEGAL_IP,"illegal ip address","非法的ip地址"},
		{BWENC_ERROR_IP_NOT_MATCH_GW,"ip not match gateway","ip地址和网关不再同一网段"},
		{BWENC_ERROR_IP_RANGE_TOOLONG,"ip range too long","扫描范围太长"},
		{BWENC_ERROR_CFGFILE_TYPE,"cfg file type error","不合法的配置文件"},
		{BWENC_ERROR_CFGFILE_DAMAGE,"cfg file damage","配置文件损坏"},
		{BWENC_ERROR_FILE_NULL,"file null","文件为空"},
		{BWENC_ERROR_INVALID_IMG,"invalid image file","图片文件格式有误"},
		{BWENC_ERROR_IP_REPEAT,"IP conflict","ip冲突，已存在相同的ip和端口"},
		{BWENC_ERROR_IP_NUM_OVAERFLOW,"IP number overflow","IP个数超过限制"},

		{BW_ERROR_UPGRADE_FILE,"upgrade file err","升级文件有误"},
		{BW_ERROR_LOCAL_XMLCFG,	"parse local xml error", "本地文件信息读取错误"},
		{BW_ERROR_BUILD_JSONCFG, "build local json error", "本地文件信息构建JSON失败"},
		{BW_ERROR_UPG_INFO, "parse upg json error", "升级文件信息读取错误"},
		{BW_ERROR_BUILD_UPGXML, "build upg xml error", "升级文件信息构造XML失败"},
		{BW_ERROR_LOAD_JSONCFG,	"load json cfg error", "JSON配置文件读取失败"},
		{BW_ERROR_PASSWORD_INVALID,	"password error", "加密密码不合法(可能为空)"},
		{BW_ERROR_OPENSSL_PKG, "openssl pkg error",	"加密文件包不合法"},
		{BW_ERROR_GET_FILEMD5, "get md5Value error", "获取文件MD5失败"},
		{BW_ERROR_VERSION_INVALID, "version invalid", "版本号异常"},
		{BW_ERROR_GET_FILEINFO, "get file information error", "获取文件信息失败"},
		{BW_ERROR_FILE_NOT_EXIST,"file not exist","导出的文件不存在"},
		{BW_ERROR_FILE_ENCRYPT,"file encrypt error","加密文件失败"},
		{BW_ERROR_FILE_ABNORMAL,"file abnormal","文件异常"},
		{BW_ERROR_GET_VERSION, "get version error", "获取版本失败"},
		{BW_ERROR_UPGSTOP_ERROR, "stop upgrade process error", "升级进程停止失败"},
};

st_ErrMsg* 	bwenc_get_errmsg(eENC_ERROR code)
{
	for (uint i = 0; i < sizeof(g_erros)/sizeof(g_erros[0]); i++)
	{
		if (code == g_erros[i].err_code)
		{
			return &g_erros[i];
		}
	}
	return NULL;
}

